package com.jianguo.web.controller.user;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jianguo.common.annotation.Log;
import com.jianguo.common.core.controller.BaseController;
import com.jianguo.common.core.domain.AjaxResult;
import com.jianguo.common.enums.BusinessType;
import com.jianguo.user.domain.PzMoney;
import com.jianguo.user.service.IPzMoneyService;
import com.jianguo.common.utils.poi.ExcelUtil;
import com.jianguo.common.core.page.TableDataInfo;

/**
 * 客户（陪诊员）余额明细Controller
 *
 * @author hxq
 * @date 2024-03-22
 */
@RestController
@RequestMapping("/user/money")
public class PzMoneyController extends BaseController
{
    @Autowired
    private IPzMoneyService pzMoneyService;

    /**
     * 查询客户（陪诊员）余额明细列表
     */
    @PreAuthorize("@ss.hasPermi('user:money:list')")
    @GetMapping("/list")
    public TableDataInfo list(PzMoney pzMoney)
    {
        startPage();
        List<PzMoney> list = pzMoneyService.selectPzMoneyList(pzMoney);
        return getDataTable(list);
    }

    /**
     * 导出客户（陪诊员）余额明细列表
     */
    @PreAuthorize("@ss.hasPermi('user:money:export')")
    @Log(title = "客户（陪诊员）余额明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PzMoney pzMoney)
    {
        List<PzMoney> list = pzMoneyService.selectPzMoneyList(pzMoney);
        ExcelUtil<PzMoney> util = new ExcelUtil<PzMoney>(PzMoney.class);
        util.exportExcel(response, list, "客户（陪诊员）余额明细数据");
    }

    /**
     * 获取客户（陪诊员）余额明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('user:money:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(pzMoneyService.getById(id));
    }

    /**
     * 新增客户（陪诊员）余额明细
     */
    @PreAuthorize("@ss.hasPermi('user:money:add')")
    @Log(title = "客户（陪诊员）余额明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PzMoney pzMoney) {
        return toAjax(pzMoneyService.save(pzMoney));
    }

    /**
     * 修改客户（陪诊员）余额明细
     */
    @PreAuthorize("@ss.hasPermi('user:money:edit')")
    @Log(title = "客户（陪诊员）余额明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PzMoney pzMoney) {
        return toAjax(pzMoneyService.updateById(pzMoney));
    }

    /**
     * 删除客户（陪诊员）余额明细
     */
    @PreAuthorize("@ss.hasPermi('user:money:remove')")
    @Log(title = "客户（陪诊员）余额明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(pzMoneyService.removeByIds(Arrays.asList(ids)));
    }
}
